import Vue from 'vue'
import Vuex from 'vuex'

//挂载Vuex
Vue.use(Vuex)

//创建VueX对象
const store = new Vuex.Store({
    state:{
        //存放的键值对就是所要管理的状态
        name:'helloVueX',
        tabbarShow:true,
        userInfo:{
            userName:"张三",
            userId:"1"
        },
        unreadMessageCount:"5"
    },
    getters:{
        userName(state){
            return state.userInfo.userName;
        },
        unreadMessageCount(state){
            return state.unreadMessageCount;
        }
    },
    mutations:{
        //隐藏底部按钮
        hideTabBar(state, payload){
            state.name = "隐藏";
            state.tabbarShow = false;
        },
        //显示底部按钮
        showTabBar(state, payload){
            state.name = "显示";
            state.tabbarShow = true;
        },
        changeUnreadMessageCount(state,payload){
            state.unreadMessageCount = payload;
        }
    },
    actions:{ 
        
    }
})

export default store